#!/bin/bash
trap 'echo Abort ; exit 1' ERR

if(test -L $0) then
    	auxlink=`ls -l $0 | sed 's/^[^>]*-> //g'`
    	M_HOME=`dirname $auxlink`/
else 
    	M_HOME=`dirname $0`/
fi
cd $M_HOME

echo Build AT91Bootstrap.
[ ! -d /opt/9263/deploy ] && { echo /opt/9263/deploy not found. ; exit 1 ; }
rm Bootstrap-v1.13 -rf
unzip -q AT91Bootstrap1.13.zip
pushd Bootstrap-v1.13 
patch --silent -p1 < ../patch
popd
pushd Bootstrap-v1.13/board/at91sam9263ek/dataflash/
make > /dev/null
cp dataflash_at91sam9263ek.bin /opt/9263/deploy/bootstrap.bin
popd
rm Bootstrap-v1.13 -rf
